package com.hson.demo.web.base.controller.school;

import java.io.IOException;
import java.io.Writer;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hson.demo.base.app.ApiModel;
import com.hson.demo.base.remote.hessian.annotations.HessianClient;
import com.hson.demo.soa.dto.ClassesDTO;
import com.hson.demo.soa.remote.ClassesServiceRemote;
import com.hson.demo.soa.remote.SchoolServiceRemote;
import com.hson.demo.web.base.controller.AbstractController;

/**
 * 
 * @author chenhs
 * 
 */
@SuppressWarnings("rawtypes")
@Controller
public class SchoolController extends AbstractController {
	
	@Autowired
	@HessianClient("soa")
	private ClassesServiceRemote clsRemote;
	@Autowired
	@HessianClient("soa")
	private SchoolServiceRemote schoolRemote;
	
	@RequestMapping
	@ResponseBody
	public ApiModel listClasses(){
		List<ClassesDTO> rs = clsRemote.listClasses();

		return buildSuccMsg(rs);
	}
	
	@RequestMapping
    public void testDate(Date date, Writer writer) throws IOException {  
       writer.write(String.valueOf (date.getTime()));  
    }  
	
	@RequestMapping
	@ResponseBody
	public ApiModel welcome() {
		return buildSuccMsg(schoolRemote.instrance("My School is CQUPT....."));
	}
}
